public class FizzBuzzPrinter {
    public String print(int num) {

        if(isDivisibleBy3And5(num)){
            return "FizzBuzz";
        }

        if (isDivisibleBy3(num)) {
            return "Fizz";
        }

        if (isDivisibleBy5(num)) {
            return "Buzz";
        }

        return String.valueOf(num);

    }

    private boolean isDivisibleBy3And5(int num) {
        return isDivisibleBy5(num) && isDivisibleBy3(num);
    }

    private boolean isDivisibleBy5(int num) {
        return num % 5 == 0;
    }

    private boolean isDivisibleBy3(int num) {
        return num % 3 == 0;
    }

    public String printAll(int num) {
        StringBuffer st = new StringBuffer();
        for(int i = 1; i < num+1; i++){
            st.append(print(i));
            st.append("\n");
        }
        return st.toString();
    }
}
